package acwing.数学.质数;

import java.util.Scanner;

/**
 * m
 *
 * @author yang
 * @date 2022/1/15
 */
public class 分解质因数 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int x = sc.nextInt();
            check(x);
        }
    }

    private static void check(int n) {
        for (int i = 2; i <= n / i; i++) {
            if (n % i == 0) {
                int s = 0;
                while (n % i == 0) {
                    n /= i;
                    s++;
                }
                System.out.println(i +" "+ s);
            }
        }
        if (n > 1) System.out.println(n +" " + 1);
        System.out.println();
    }

}
